// ****************************************************************************
// @File: Lock.h
//
// PURPOSE: the lock implement to ensure sync
// AUTHOR:  Zj Ai
//
// NOTES: 
//     
// HISTORY:
//
//   ------ Zj Ai  05/07/2012 creating the file
//
// @EndHeader@
// ****************************************************************************

#pragma once
#include "stdafx.h"
#include "GlobalDefinition.h"

//lock
static CRITICAL_SECTION cs_lock;

class  Lock
{
public:
	Lock() 
	{
		static bool inited = false;
		if(!inited)
		{
			InitializeCriticalSection(&cs_lock);
			inited = true;
		}
		EnterCriticalSection(&cs_lock); 
	}

	~Lock() 
	{ 
		LeaveCriticalSection(&cs_lock); 
	}
};
